<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var cat = {
            name: '喵喵',
            eatFish: function (param1, param2) {
                console.log("吃鱼")
                console.log('this 的指向 =>')
                console.log(this) // this的指向被call,apply给改变了，现在指向dog
                console.log(param1, param2)
            }
        }
        var dog = {
            name: '汪汪',
            eatBone: function (param1, param2) {
                console.log("吃骨头")
                console.log('this 的指向 =>')
                console.log(this)
                console.log(param1, param2)
            }
        }

        cat.eatFish.call(dog, '分配给汪汪的鱼', '改变this的指向')
        // 吃鱼
        // this 的指向 =>
        // {name: "汪汪", eatBone: ƒ}
        // 分配给汪汪的鱼 改变this的指向

        cat.eatFish.apply(dog, ['分配给汪汪的鱼', '改变this的指向'])
        // 吃鱼
        // this 的指向 =>
        // {name: "汪汪", eatBone: ƒ}
        // 分配给汪汪的鱼 改变this的指向

    </script>
</head>

<body>

</body>

</html>